package com.xqb.modules.domain.dto;


import lombok.Data;
import org.elasticsearch.search.sort.SortOrder;

/**
 * @Author: JinChen Zhu
 * @CreateTime: 2024-10-29  21:02
 */
@Data
public class SearchParamsDto {
    /**
     * 搜索关键字
     */
    private String keyword = "";
    /**
     * 当前页码
     */
    private Integer pageNum = 0;
    /**
     * 每页显示条数
     */
    private Integer pageSize = 8;
    /**
     * 排序类型：0-相关度，1-时间，2-价格，3-销量
     */
    private Integer sort = 0;
    /**
     * 排序方式：0-降序，1-升序
     */
    private Integer isAsc = 0;


    /**
     * 精确搜索字段
     */
    private Long courseType = 0L;
    private Long insId = 0L;
    private Long thirdCateId = 0L;
    private String teacherName = "";

    public boolean isFilterable() {
        return courseType != null && courseType != 0
                || insId != null && insId != 0
                || thirdCateId != null && thirdCateId != 0
                || teacherName != null && !teacherName.isEmpty();
    }

    public SortOrder isAsc() {
        return isAsc == 0 ? SortOrder.DESC : SortOrder.ASC;
    }

}
